<template>
	<view class="im-item-box">
		<view class="im-time" v-if="itemInvite.datetime">
			{{itemInvite.datetime}}
		</view>
		<view class="delivery-title">
			<!-- 企业邀请您投递简历 -->
			{{itemInvite.self_side == 1?'邀请对方投递简历':'企业邀请您投递简历'}}
		</view>
		<view class="delivery-box">
			<view class="delivery-top">
				<view class="delivery-info">
					<view class="delivery-name substring">{{itemInvite.message.jobname}}</view>
					<view class="delivery-salary substring">{{itemInvite.message.wage_text}}</view>
				</view>
				<view class="delivery-demand">
					<view class="demand-item">{{itemInvite.message.education_text}}</view>
					<view class="demand-item">{{itemInvite.message.experience_text}}</view>
					<view class="demand-item">{{itemInvite.message.district_text}}</view>
				</view>
			</view>
			<view class="delivery-bottom">
				<view v-if="itemInvite.self_side == 1">
					<view class="delivery-btn delivery-btn-ac" v-if="itemInvite.message.status==0">等待对方投递</view>
					<view class="delivery-btn" v-else @click="handleSeeResume">对方已投递 立即查看</view>
				</view>
				<view v-else>
                  <view class="delivery-btn" v-if="itemInvite.message.status == 0" @click="handleDeliverResume">投递简历</view>
                  <view class="delivery-btn delivery-btn-ac" v-else>已投递</view>
                </view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		parseTime,
		formatTime
	} from '@/utils/index.js'
	import {
		mapState
	} from 'vuex'
	export default {
		props: ['itemInvite'],
		filters: {
			timeFilter(timestamp) {
				return formatTime(timestamp, '{y}-{m}-{d}', true)
			},
			interviewTimeFilter(timestamp) {
				return parseTime(timestamp, '{y}-{m}-{d} {h}:{i}')
			}
		},
		computed: {
			...mapState(['imToken'])
		},
		methods: {
			/**
			 * 投递简历
			 */
			handleDeliverResume() {
				var msgObj = {
					controller: 'SendInvite',
					action: 'applyjob',
					args: {
						token: this.imToken,
						messageid: this.itemInvite.messageid
					}
				}
				var msgStr = JSON.stringify(msgObj)
				this.$ws.send(msgStr)
			},
			/**
			 * 查看简历
			 */
			handleSeeResume() {
				uni.navigateTo({
					url:'/commonViews/ResumeShow?id=' + this.itemInvite.message.resumeid
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	//发送职位开始 / 企业邀请投递简历开始
	.delivery-title {
		margin: 0 36rpx;
		color: #333333;
		font-size: 34rpx;
		height: 98rpx;
		line-height: 98rpx;
		font-weight: bold;
		border-bottom: 2rpx solid #ededed;
		background: #fff;
		padding: 0 30rpx;
	}

	.delivery-box {
		margin: 0 36rpx;
		max-height: 550rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		font-size: 28rpx;
		padding: 0 30rpx;

		.delivery-top {
			padding: 30rpx 0;
			border-bottom: 2rpx solid #ededed;

			.delivery-info {
				display: flex;
				margin-bottom: 20rpx;
				align-items: center;
				.delivery-name {
					flex: 2.5;
					color: #2E2E2E;
					font-size: 34rpx;
					font-weight: bold;
					margin-right: 60rpx;
				}

				.delivery-salary {
					flex: 1.5;
					// color: $textActiveColor;
					font-size: 28rpx;
					text-align: right;
				}
			}

			.delivery-demand {
				display: flex;
				flex-wrap: wrap;

				.demand-item {
					color: #666666;
					font-size: 24rpx;
					margin-right: 20rpx;
					background: #F8F8F8;
					padding: 10rpx 20rpx;
					border-radius: 10rpx;
					&:last-child {
						margin-right: 0;
					}
				}
			}
		}

		.delivery-bottom {
			padding: 24rpx 0 24rpx;

			.company-info-box {
				display: flex;
				margin-bottom: 26rpx;

				.company-img {
					width: 64rpx;
					height: 64rpx;
					margin-right: 34rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				// .company-info{
				//   width: calc(345px - 32px - 17px - 32px);
				//   .company-name{
				//     color: #333333;
				//     font-size: 13px;
				//     font-weight: bold;
				//   }
				//   .company-text{
				//     color: #999999;
				//     font-size: 12px;
				//   }
				// }
			}

			.company-time {
				color: #999999;
				font-size: 26rpx;
			}

			.delivery-btn {
				width: 500rpx;
				height: 70rpx;
				background: #1787fb;
				border-radius: 34rpx;
				text-align: center;
				line-height: 70rpx;
				color: #fff;
				margin: 0 auto 0;

				&.delivery-btn-ac {
					background: #CECECE;
				}
			}
		}
	}
</style>
